Step 3: Edit the VB code to close the main report document

At 1. Write the VB code we modified the VB code by commenting out MainDocument.Close SaveChanges:=False. Before we finalise the report we need to edit the VB code to remove the apostrophe. Once this is done only the mail merge document will display whenever the report is run:

  1. Open the main report document.

    The Security box displays:

    Macro Security

  2. Click Disable Macros.

    Only the main report document opens (i.e. the mail merge document is not generated).

  3. Select Tools>Macro>Visual Basic Editor from the Menu bar.

    The Microsoft Visual Basic editor opens.

  4. Under the Project (Document 1) folder in the left Project pane, double-click ThisDocument to display the Visual Basic code for the mail merge in the right pane:

    VB Code

  5. Remove the apostrophe (') from before Main Document.Close SaveChanges :=False
  6. Select File>Close and Return to Microsoft Word from the Visual Basic editor Menu bar.
  7. Save the main report document and close MS Word.

Next we save the report back to EMu and run it.